<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=11"/>
<meta name="generator" content="Doxygen 1.10.0"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>common_util: common_util</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script type="text/javascript" src="clipboard.js"></script>
<script type="text/javascript" src="cookie.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr id="projectrow">
  <td id="projectalign">
   <div id="projectname">common_util
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.10.0 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search/",'.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
</div><!-- top -->
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<div id="MSearchResults">
<div class="SRPage">
<div id="SRIndex">
<div id="SRResults"></div>
<div class="SRStatus" id="Loading">Loading...</div>
<div class="SRStatus" id="Searching">Searching...</div>
<div class="SRStatus" id="NoMatches">No Matches</div>
</div>
</div>
</div>
</div>

<div><div class="header">
  <div class="headertitle"><div class="title">common_util </div></div>
</div><!--header-->
<div class="contents">
<div class="textblock"><h2><a class="anchor" id="autotoc_md50"></a>
1. Source code</h2>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Region   </th><th class="markdownTableHeadNone">Platform   </th><th class="markdownTableHeadNone">Source Code Repository URL    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Mainland China   </td><td class="markdownTableBodyNone">gitcode   </td><td class="markdownTableBodyNone"><a href="https://gitcode.com/luoweifu1/common_util">https://gitcode.com/luoweifu1/common_util</a>    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Mainland China   </td><td class="markdownTableBodyNone">Gitee   </td><td class="markdownTableBodyNone"><a href="https://gitee.com/spencer_luo/common_util">https://gitee.com/spencer_luo/common_util</a>    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">International   </td><td class="markdownTableBodyNone">Github   </td><td class="markdownTableBodyNone"><a href="https://github.com/spencer-luo/common_util">https://github.com/spencer-luo/common_util</a>   </td></tr>
</table>
<h2><a class="anchor" id="autotoc_md51"></a>
2. Overview</h2>
<p>common_util is a general-purpose C++ utility library, include the following functions:</p>
<ul>
<li>Time utilities</li>
<li>Function timer</li>
<li>Filepath utilities</li>
<li>Filesystem utilities</li>
<li>String utilities</li>
<li>Data formatting</li>
<li>Singleton pattern macro definition</li>
</ul>
<p>common_util is implemented in modern C++ syntax (C++11 and above), using cutl as the namespace. The naming convention of all interfaces is consistent with the STL, and it can be used as an extensions of C++ standard library. You can use common_util just like using the STL, For example:</p>
<div class="fragment"><div class="line"> ++</div>
<div class="line"><span class="comment">// Data formatting</span></div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;fmt_uint: &quot;</span> &lt;&lt; cutl::fmt_uint(12, 5) &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;fmt_double: &quot;</span> &lt;&lt; cutl::fmt_double(3.141592653, 4) &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;fmt_filesize: &quot;</span> &lt;&lt; cutl::fmt_filesize(33600) &lt;&lt; std::endl;</div>
<div class="line"><span class="comment">// Get the current system time</span></div>
<div class="line"><span class="keyword">auto</span> now = <a class="code hl_function" href="classcutl_1_1datetime.html#a2f26f17577618f7133b62b0343ecca0c">cutl::datetime::now</a>();</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;current time(UTC time): &quot;</span> &lt;&lt; now.utctime() &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;current time(local time): &quot;</span> &lt;&lt; now.format() &lt;&lt; std::endl;</div>
<div class="ttc" id="aclasscutl_1_1datetime_html_a2f26f17577618f7133b62b0343ecca0c"><div class="ttname"><a href="classcutl_1_1datetime.html#a2f26f17577618f7133b62b0343ecca0c">cutl::datetime::now</a></div><div class="ttdeci">static datetime now()</div><div class="ttdoc">Get a datetime object for the current system time.</div></div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md52"></a>
3. Library Features</h2>
<ul>
<li><b>Simple and lightweigh</b>: Based on basic C++ syntax and STL, it independent on any third-party libraries.</li>
<li><b>Multi-platform support</b>: Supports multiple platforms such as Linux/macOS/Windows, it can be compiled and run on multiple platforms.</li>
<li><b>Clean code</b>: The code style is clean, and the naming convention is consistent with the STL, you can use this library just like use the C++ standard library.</li>
<li><b>Comprehensive documentation</b>: All exported header files have detail comments, it has complete API reference and usage demos.</li>
<li><b>C++ version requirement</b>: C++11 and above versions.</li>
</ul>
<h2><a class="anchor" id="autotoc_md53"></a>
4. Testing Platforms</h2>
<p>This library has been tested and verified on the following platforms:</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">Operating System Platform and Version   </th><th class="markdownTableHeadNone">C++ Compiler and Version   </th><th class="markdownTableHeadNone">Testing Status   </th><th class="markdownTableHeadNone">Remarks    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Windows 10   </td><td class="markdownTableBodyNone">Visual Studio 2015   </td><td class="markdownTableBodyNone">tested   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Ubuntu 20.04.4   </td><td class="markdownTableBodyNone">GNU GCC 9.4.0   </td><td class="markdownTableBodyNone">tested   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">macOS xxx   </td><td class="markdownTableBodyNone">Clang version 15.0.0   </td><td class="markdownTableBodyNone">tested   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Android   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">To be tested   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">iOS   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">To be tested   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">HarmonyOS   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">To be tested   </td><td class="markdownTableBodyNone"></td></tr>
</table>
<h2><a class="anchor" id="autotoc_md54"></a>
5. Related Documents</h2>
<ul>
<li>off-line: <a href="./docs/reference/html/index.html">docs/reference/html/index.html</a></li>
<li>on line : <a href="http://sunlogging.com/docs/common_util/">http://sunlogging.com/docs/common_util/</a></li>
</ul>
<h2><a class="anchor" id="autotoc_md55"></a>
6. Welcome to Collaborate</h2>
<p>We welcome all developers who are interested in this project to join us, whether you are an experienced senior developer or a newcomer just starting out, we look forward to your participation. You can get involved in the project in the following ways:</p>
<ul>
<li><b>Code Contribution:</b> You can fork our code repository, conduct code development, and submit your code via a pull request.</li>
<li><b>Issue Feedback:</b> If you encounter any problems during use or have any suggestions, feel free to raise them in the issue section.</li>
<li><b>Documentation Writing:</b> We welcome you to write documentation for the project, helping other developers better understand and use our project.</li>
<li><b>Testing and Feedback:</b> You can assist us in code testing and provide valuable feedback.</li>
</ul>
<p>If you have any questions or need help, please feel free to contact me through the following methods:</p>
<p>Email: [<a href="#" onclick="location.href='mai'+'lto:'+'spe'+'nc'+'er.'+'lu'+'o@f'+'ox'+'mai'+'l.'+'com'; return false;">spenc<span class="obfuscator">.nosp@m.</span>er.l<span class="obfuscator">.nosp@m.</span>uo@fo<span class="obfuscator">.nosp@m.</span>xmai<span class="obfuscator">.nosp@m.</span>l.com</a>]</p>
<p>Looking forward to your participation!</p>
<h2><a class="anchor" id="autotoc_md56"></a>
7. 源码仓库</h2>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">地区   </th><th class="markdownTableHeadNone">代码托管平台   </th><th class="markdownTableHeadNone">源码仓库地址    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">中国大陆   </td><td class="markdownTableBodyNone">gitcode   </td><td class="markdownTableBodyNone"><a href="https://gitcode.com/luoweifu1/common_util">https://gitcode.com/luoweifu1/common_util</a>    </td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">中国大陆   </td><td class="markdownTableBodyNone">Gitee   </td><td class="markdownTableBodyNone"><a href="https://gitee.com/spencer_luo/common_util">https://gitee.com/spencer_luo/common_util</a>    </td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">国际站点   </td><td class="markdownTableBodyNone">Github   </td><td class="markdownTableBodyNone"><a href="https://github.com/spencer-luo/common_util">https://github.com/spencer-luo/common_util</a>   </td></tr>
</table>
<h2><a class="anchor" id="autotoc_md57"></a>
8. 概述</h2>
<p>common_util是C++的一个通用工具库，主要包含以下功能：</p>
<ul>
<li>时间处理</li>
<li>函数计时器</li>
<li>路径处理</li>
<li>文件操作</li>
<li>字符串处理</li>
<li>数据格式化</li>
<li>单例模式宏定义</li>
</ul>
<p>common_util采用现代C++语法（C++11及以上）实现，使用cutl作为命名空间，所有接口的命名方式与STL保持一致，可以作为STL库的一个补充。你可以像使用STL一样使用common_util，如：</p>
<div class="fragment"><div class="line"> ++</div>
<div class="line"><span class="comment">// 数据格式化</span></div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;fmt_uint: &quot;</span> &lt;&lt; cutl::fmt_uint(12, 5) &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;fmt_double: &quot;</span> &lt;&lt; cutl::fmt_double(3.141592653, 4) &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;fmt_filesize: &quot;</span> &lt;&lt; cutl::fmt_filesize(33600) &lt;&lt; std::endl;</div>
<div class="line"><span class="comment">// 获取系统当前时间</span></div>
<div class="line"><span class="keyword">auto</span> now = <a class="code hl_function" href="classcutl_1_1datetime.html#a2f26f17577618f7133b62b0343ecca0c">cutl::datetime::now</a>();</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;current time(UTC time): &quot;</span> &lt;&lt; now.utctime() &lt;&lt; std::endl;</div>
<div class="line">std::cout &lt;&lt; <span class="stringliteral">&quot;current time(local time): &quot;</span> &lt;&lt; now.format() &lt;&lt; std::endl;</div>
</div><!-- fragment --><h2><a class="anchor" id="autotoc_md58"></a>
9. 设计特点</h2>
<ul>
<li>**轻量极简**： 基于基础C++语法和STL，不依赖任何第三方库。</li>
<li>**多平台支持**： 支持Linux/OS-X/Windows等多个平台，一套代码多平台编译。</li>
<li>**代码整洁**： 代码风格整洁，命名方式与STL保持一致，你可以像使用STL一样使用本库。</li>
<li>**文档规范全面**： 所有对外接口的头文件都有详细的代码注释，且有完整的API文档和使用Demo，可供查阅。</li>
<li>**C++版本要求**： C++11及以上版本。</li>
</ul>
<h2><a class="anchor" id="autotoc_md59"></a>
10. 已验证的平台</h2>
<p>本库在以下平台上测试验证过：</p>
<table class="markdownTable">
<tr class="markdownTableHead">
<th class="markdownTableHeadNone">操作系统平台及版本   </th><th class="markdownTableHeadNone">C++编译器及版本   </th><th class="markdownTableHeadNone">验证状态   </th><th class="markdownTableHeadNone">备注    </th></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">Windows 10   </td><td class="markdownTableBodyNone">Visual Studio 2015   </td><td class="markdownTableBodyNone">已验证   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Ubuntu 20.04.4   </td><td class="markdownTableBodyNone">GNU GCC 9.4.0   </td><td class="markdownTableBodyNone">已验证   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">macOS xxx   </td><td class="markdownTableBodyNone">Clang version 15.0.0   </td><td class="markdownTableBodyNone">已验证   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">Android   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">待验证   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowOdd">
<td class="markdownTableBodyNone">iOS   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">待验证   </td><td class="markdownTableBodyNone"></td></tr>
<tr class="markdownTableRowEven">
<td class="markdownTableBodyNone">HarmonyOS   </td><td class="markdownTableBodyNone"></td><td class="markdownTableBodyNone">待验证   </td><td class="markdownTableBodyNone"></td></tr>
</table>
<h2><a class="anchor" id="autotoc_md60"></a>
11. 相关文档</h2>
<ul>
<li>离线文档: <a href="./docs/reference/html/index.html">docs/reference/html/index.html</a></li>
<li>在线文档: <a href="http://sunlogging.com/docs/common_util/">http://sunlogging.com/docs/common_util/</a></li>
</ul>
<h2><a class="anchor" id="autotoc_md61"></a>
12. 欢迎共建</h2>
<p>我们欢迎所有对此项目感兴趣的开发者加入我们，无论您是经验丰富的资深开发者，还是刚刚入门的新手，我们都期待您的参与。您可以通过以下方式参与到项目中：</p>
<ul>
<li><b>代码贡献：</b> 您可以 fork 我们的代码仓库，进行代码开发，并通过 pull request 提交您的代码。</li>
<li><b>问题反馈：</b> 如果您在使用过程中遇到任何问题或有任何建议，欢迎在 issue 区提出。</li>
<li><b>文档编写：</b> 我们欢迎您为项目编写文档，帮助其他开发者更好地理解和使用我们的项目。</li>
<li><b>测试与反馈：</b> 您可以帮助我们进行代码测试，并提供宝贵的反馈意见。</li>
</ul>
<p>如果您有任何疑问或需要帮助，欢迎通过以下方式联系我：</p>
<p>邮箱：[<a href="#" onclick="location.href='mai'+'lto:'+'spe'+'nc'+'er.'+'lu'+'o@f'+'ox'+'mai'+'l.'+'com'; return false;">spenc<span class="obfuscator">.nosp@m.</span>er.l<span class="obfuscator">.nosp@m.</span>uo@fo<span class="obfuscator">.nosp@m.</span>xmai<span class="obfuscator">.nosp@m.</span>l.com</a>]</p>
<p>期待你的参与！ </p>
</div></div><!-- PageDoc -->
<a href="doxygen_crawl.html"/>
</div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by&#160;<a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.10.0
</small></address>
</body>
</html>
